package cha;

import static org.junit.Assert.assertFalse;
import robocode.control.events.TurnEndedEvent;
import robocode.control.snapshot.IRobotSnapshot;
import robocode.control.snapshot.RobotState;
import robocode.control.testing.RobotTestBed;

/**
 * Test if bullet power fired at the enemy is greater than 2.4.
 *
 *@author Hansen Cheng 
 */
public class TestNotAlive extends RobotTestBed {

  // True if Destroyer dies in a battle
  boolean notAlive = false;
  
  /**
   * Specifies that SittingDuck and Destroyer robot will be in this battle.
   * 
   * @return The comma-delimited list of robots in this match.
   */
  @Override public String getRobotNames() {

    return "sample.SittingDuck,cha.Destroyer";
  }
  
  /**
   * This test runs for 10 rounds.
   * 
   * @return The number of rounds. 
   */
  @Override public int getNumRounds() {
    
    return 10;
  }
  
  /**
   * At the end of each turn test if Destroyer is still alive
   * after battling against RamFire.
   * 
   * @param event - to catch the action of the robot after the turn ends.
   */
  @Override public void onTurnEnded (TurnEndedEvent event) {
    
    // All active bullets belong to Destroyer since SittingDuck does not fire.
    IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1];
    
    RobotState hit = robot.getState();
    
    if (hit.isDead()) {
      notAlive = false;
    }
    assertFalse("Destroyer is not alive", notAlive);  
  }
  
}